package com.tencent.feign;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.tencent.User;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;

public class UserFallBack{
        // openfeign的熔断方式
//    @Override
//    public UserService create(Throwable throwable) {
//        return new UserService() {
//
//            @Override
//            public User findUserById(Long id) {
//                return new User(-1L, "熔断器", "fallbackFactory的回调页面");
//            }
//        };
//    }

    // 限流方法必须要求传入一个BlockException
    public static User findUserByIdFallback(@PathVariable("id") Long id){
        return new User(-1L, "sentinel熔断了", "你们不要再挤了");
    }
}
